$(function () {
    $(".change_pwd").change(function () {
        check_input(/^[a-zA-Z\d_]{8,}$/,$(this).val(),$(this))
    })
    $(".change_rpwd").change(function () {
        if($(this).val() == $(".change_pwd").val()){
            $(this).parent().parent().prop("class","weui-cell weui-cell_success").find("i").prop("class","weui-icon-success")
        }else{
            $(this).parent().parent().prop("class","weui-cell weui-cell_warn").find("i").prop("class","weui-icon-warn")
        };
    })
    $(".change_yzm").change(function () {
        check_input(/^[0-9_]{4}$/,$(this).val(),$(this))
    })
    $(".change_click").click(function () {
        console.log(0)
        if(/^1(3|4|5|7|8)\d{9}$/.test($(".change_phone").val()) && /^[a-zA-Z\d_]{8,}$/.test($(".change_pwd").val()) && /^[0-9_]{4}$/.test($(".change_yzm").val()) && $(".change_rpwd").val() == $(".change_pwd").val()){
            console.log(1);
            $.ajax({
                url:"../../../front/php/change.php",
                data: {phone:$(".change_phone").val(),pwd:$(".change_pwd").val(),yzm:$(".change_yzm").val()},
                dataType:"json",
                type:"GET",
                success:function (d) {
                    if(d.code == "S"){
                        window.location.href = "../index.html"
                    }
                }
            })
        }
    })
    function check_input(reg,val,that) {
        if(reg.test(val)){
            that.parent().parent().prop("class","weui-cell weui-cell_success").find("i").prop("class","weui-icon-success")
        }else{
            that.parent().parent().prop("class","weui-cell weui-cell_warn").find("i").prop("class","weui-icon-warn")
        };
    }
})